<%@ page contentType="text/html;charset=utf-8"%>
<html>
<head>
<link rel="stylesheet" href="css/registerstyle.css">
<script type="text/javascript" src="js/jquery-3.1.0.min.js"></script>
<script type="text/javascript" src="js/registereasyform.js"></script>
 <script type="text/javascript">

        $(document).ready(function(){
        	$("#msg").hide();
        	$("#uid").blur(function(){
            	var data={uid:$("#uid").val()};
            	 $.ajax({
    		            type: "post",
    		            url: "userVerification.action",
    		            data: data,
    		            success: function(msg) {
    			           if(msg == "success"){
    			        	$("#msg").hide();
    			           }else{$("#msg").show();}
    			           }
    		     });
        	});
        	
            $("#register").click(function(){
                var uid=$("#uid").val();
                var nickname=$("#nickname").val();
                var realName=$("#realName").val();
                var telephone=$("#telephone").val();
                var email=$("#email").val();
                var t1=/^[a-zA-Z][a-zA-Z0-9]{3,15}/;
                var t2=/^[a-zA-Z0-9\u4e00-\u9fa5]+$/;
                var t3 =/^(13[0-9]|14[0-9]|15[0-9]|18[0-9])\d{8}$/;
                var t4=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
                if(t1.test(uid) && t2.test(nickname)&& t3.test(telephone)&& t4.test(email)&& ($("#psw1").val()==$("#psw2").val())&& realName!="")
            {	    
                 
                	var data={uid:$("#uid").val()};
                 	 $.ajax({
       		            type: "post",
       		            url: "userVerification.action",
       		            data: data,
       		            success: function(msg) {
       			           if(msg == "success"){
       			        	 $("#reg-form").submit();
       			           }
       			           }
       		     });
            }
            });
            $('#reg-form').easyform();
            $("#login").click(function(){
            	window.location.href="login.jsp";
            });
        });
    </script>
</head>
<body>
<br>
<div class="form-div">
    <form id="reg-form" action="addUser.action" method="post">

        <table>
            <tr>
                <td>用户名</td>
                <td><input name="uid" type="text" id="uid" easyform="length:4-16;char-normal;real-time;" message="用户名必须为以字母开头的4—16位的英文字母或数字" easytip="disappear:lost-focus;theme:blue;">
                </td>
            </tr>
            <span id="msg" style="color:red; position:absolute;left:578px;top:106px;">*用户名已存在！</span>
            <tr>
                <td>昵称</td>
                <td><input name="nickname" type="text" id="nickname" easyform="length:2-16;real-time" message="昵称必须为2—16位" easytip="disappear:lost-focus;theme:blue;"></td>
            </tr>
            <tr>
                <td>真实姓名</td>
                <td><input name="realName" type="text" id="realName" />
                </td>
            </tr>
            <tr>
                <td>性别</td>
                <td class="sex">男&nbsp&nbsp&nbsp<input  name="sex" type="radio" value="male" checked/></td>
                <td class="sex">女&nbsp&nbsp&nbsp<input name="sex" type="radio" value="female"/></td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input name="psw1" type="password" id="psw1" easyform="length:6-16;real-time" message="密码必须为6—16位" easytip="disappear:lost-focus;theme:blue;"></td>
            </tr>
            <tr>
                <td>确认密码</td>
                <td><input name="psw2" type="password" id="psw2" easyform="length:6-16;equal:#psw1;real-time;" message="两次密码输入要一致" easytip="disappear:lost-focus;theme:blue;"></td>
            </tr>
            <tr>
                <td>手机号</td>
                <td><input name="telephone" type="text" id="telephone" easyform="length:11;telephone;real-time;" message="手机号格式不正确" easytip="disappear:lost-focus;theme:blue;" >
                </td>
            </tr>
            <tr>
                <td>email</td>
                <td><input name="email" type="text" id="email" easyform="email;real-time;" message="Email格式要正确" easytip="disappear:lost-focus;theme:blue;" ajax-message="这个Email地址已经被注册过，请换一个吧!"></td>
            </tr>

        </table>

		<div class="buttons">
			<input value="注 册" type="button" id="register" style="margin-right:20px; margin-top:20px;"/>
			<input value="我有账号，我要登录" id="login" type="button" style="margin-right:45px; margin-top:20px;"/>
        </div>
		
        <br class="clear">
    </form>
</div>
</body>
</html>